package com.catsic.security;

import javax.servlet.FilterRegistration;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;

import org.springframework.security.web.session.HttpSessionEventPublisher;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.filter.DelegatingFilterProxy;

public class SecurityIniializer implements WebApplicationInitializer {

	@Override
	public void onStartup(ServletContext servletContext)
			throws ServletException {
		/**
		 * security过滤器
		 */
		FilterRegistration.Dynamic springSecurityFilterChain=servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy());
		springSecurityFilterChain.addMappingForUrlPatterns(null, false, "/*"); 
		/**
		 * session监听
		 */
		servletContext.addListener(new HttpSessionEventPublisher());
	}
}
